import axios from 'axios'
import { Toast } from 'vant'
import Vue from 'vue'
Vue.use(Toast)

const http = axios.create({
  baseURL: 'https://m.maizuo.com',
  timeout: 10000,
  Headers: {
    'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.0.4","e":"16150113011063240628961281"}'

  }
})
// axios拦截器
// http.interceptors.request() 请求拦截器
// http.interceptors.response() 响应拦截器
http.interceptors.request.use(function (config) {
  // 启动loding
  // 显示一个loding
  Toast.loading({
    message: '加载中...',
    forbidClick: true,
    overlay: true,
    loadingType: 'spinner',
    duration: 500
  })
  return config
}, function (error) {
  return Promise.reject(error)
})
http.interceptors.response.use(function (response) {
  Toast.clear()
  return response
}, function (error) {
  return Promise.reject(error)
})
export default http
